package com.cnzz.site1255174697.holder;

import android.app.Activity;
import android.content.Context;
import android.graphics.PointF;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.cnzz.site1255174697.ConstHost;
import com.cnzz.site1255174697.R;
import com.cnzz.site1255174697.model.BigEntity;
import com.cnzz.site1255174697.utils.AlibcTradeUtils;
import com.cqyanyu.yanyu.view.recyclerView.YViewHolder;
import com.facebook.drawee.view.SimpleDraweeView;

/**
 * 非常大牌
 */
public class BigViewHolder extends YViewHolder<BigEntity> {

    protected SimpleDraweeView ivImg;
    protected TextView tvTitle;
    protected TextView tvState;
    private Context context;
    private BigEntity bigEntity;

    public BigViewHolder(View parent) {
        super(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_super_big, null));
        context = parent.getContext();
        ivImg = (SimpleDraweeView) itemView.findViewById(R.id.iv_img);
        tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
        tvState = (TextView) itemView.findViewById(R.id.tv_state);
    }

    @Override
    public void onBindViewHolder(BigEntity itemData) {
        super.onBindViewHolder(itemData);
        bigEntity = itemData;
        PointF focusPoint = new PointF(0.5f, 0.5f);
        ivImg.getHierarchy().setActualImageFocusPoint(focusPoint);
        ivImg.setImageURI(ConstHost.IMG_BASE_URL + bigEntity.getImg());
        tvTitle.setText(bigEntity.getName());
        tvState.setText(bigEntity.getType_msg());
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        AlibcTradeUtils.showUrl((Activity) context, bigEntity.getUrl());
    }
}
